
package week8;

import java.util.*;
import java.util.Map.Entry;
public class ptajihe03 {
	
	
	
	 public static void main(String[] args) {
		 Scanner sc=new Scanner(System.in);
		 HashMap<String,Integer>dict =new HashMap<>();
		 while(sc.hasNext()){
			 String line =sc.nextLine();
			 if("!!!!!".equals(line))
				 break;
			 Scanner lineScanner =new Scanner(line);
			 while(lineScanner.hasNext()){
			 String str=lineScanner.next();
			// for (String e :str) {
				 if(dict.containsKey(str))
					 dict.put(str, dict.get(str)+1);
					 
				 
				 else
					 dict.put(str, 1);

			 }
			 lineScanner.close();
			 
			 
			 }
				   
		// sc.close();
			
			/*System.out.println(dict.size());
			 
				//for(Map.Entry<String,Integer> entry : dict.entrySet()){
			 List<Entry<String,Integer>> list =new ArrayList<Entry<String,Integer>>();
			 dict.entrySet();
					Collections.sort(list,new Comparator<Entry<String,Integer>>(){

						@Override
						public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
							// TODO Auto-generated method stub
							if(o2.getValue()-o1.getValue()!=0)
								return o2.getValue()-o1.getValue();
							
							return o1.getKey().compareTo(o2.getKey());
						}
						
					});
				 // System.out.println(entry.getKey() +"="+entry.getValue());
					/*int i=0;
					for (Map.Entry<String, Integer> entry: list) {
						i++;
						System.out.println(entry.getKey() +"="+entry.getValue());
						System.out.println(entry);
						if(i==10)
					break;
					}*/
						
		 List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(dict.entrySet());
			Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {

				@Override
				public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
					if (o1.getValue() == o2.getValue()) {
						return o1.getKey().compareTo(o2.getKey());
					}
					return o2.getValue() - o1.getValue();
				}

			});
			System.out.println(dict.size());
			int num = 0;
			for (Map.Entry<String, Integer> m : list) {
				if (num == 10)
					break;
				System.out.println(m.getKey() + "=" + m.getValue());
				num++;
			}

			sc.close();

		}

		
			 
			 
		 
		
	}

	 






